//
// Created by PC on 2017/11/16.
//

#ifndef SELECTION_TESTHELPER_H
#define SELECTION_TESTHELPER_H
#include <iostream>
#include <algorithm>
#include <ctime>

using namespace std;

namespace TestHelper {
    int *generateRandomArray(int n, int range_l, int range_r) {

        int *arr = new int[n];

        srand(time(NULL));
        for (int i = 0; i < n; i++)
            arr[i] = rand() % (range_r - range_l + 1) + range_l;
        return arr;
    }
    // 生成一个完全有序的数组
    int *generateOrderedArray(int n) {

        int *arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = i;

        return arr;
    }

    // 将数组arr随机化
    void shuffleArray(int arr[], int n){

        srand(time(NULL));
        for (int i = 0; i < n; i++) {
            int j = rand() % (n-i)+i;
            swap( arr[i], arr[j]);
        }
    }
    template <typename T>
    void printfArray(T arr[],int n){
        for (int i = 0; i < n; i++)
            cout<<arr[i]<<" ";
        return;
    }
}
#endif //SELECTION_TESTHELPER_H
